package practise;

import java.util.HashSet;
import java.util.Set;

public class SingleNumber {
    // 不用亦或
    public int singleNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for(int num : nums) {
            if(set.contains(num)) {
                set.remove(num);
            } else {
                set.add(num);
            }
        }

        int ret = 0;
        for(int n : set) {
            ret = n;
        }
        return ret;
    }
}
